package com.ruoyi.wcf.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.wcf.domain.WcfProductModel;
import com.ruoyi.wcf.service.IWcfProductModelService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 产品编号Controller
 * 
 * @author WZP
 * @date 2022-04-02
 */
@RestController
@RequestMapping("/wcf/WcfProductModel")
public class WcfProductModelController extends BaseController
{
    @Autowired
    private IWcfProductModelService wcfProductModelService;

    /**
     * 查询产品编号列表
     */
    @PreAuthorize("@ss.hasPermi('wcf:WcfProductModel:list')")
    @GetMapping("/list")
    public TableDataInfo list(WcfProductModel wcfProductModel)
    {
        startPage();
        List<WcfProductModel> list = wcfProductModelService.selectWcfProductModelList(wcfProductModel);
        return getDataTable(list);
    }

    /**
     * 导出产品编号列表
     */
    @PreAuthorize("@ss.hasPermi('wcf:WcfProductModel:export')")
    @Log(title = "产品编号", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(WcfProductModel wcfProductModel)
    {
        List<WcfProductModel> list = wcfProductModelService.selectWcfProductModelList(wcfProductModel);
        ExcelUtil<WcfProductModel> util = new ExcelUtil<WcfProductModel>(WcfProductModel.class);
        return util.exportExcel(list, "产品编号数据");
    }

    /**
     * 获取产品编号详细信息
     */
    @PreAuthorize("@ss.hasPermi('wcf:WcfProductModel:query')")
    @GetMapping(value = "/{modelId}")
    public AjaxResult getInfo(@PathVariable("modelId") Long modelId)
    {
        return AjaxResult.success(wcfProductModelService.selectWcfProductModelByModelId(modelId));
    }

    /**
     * 新增产品编号
     */
    @PreAuthorize("@ss.hasPermi('wcf:WcfProductModel:add')")
    @Log(title = "产品编号", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WcfProductModel wcfProductModel)
    {
        return toAjax(wcfProductModelService.insertWcfProductModel(wcfProductModel));
    }

    /**
     * 修改产品编号
     */
    @PreAuthorize("@ss.hasPermi('wcf:WcfProductModel:edit')")
    @Log(title = "产品编号", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WcfProductModel wcfProductModel)
    {
        return toAjax(wcfProductModelService.updateWcfProductModel(wcfProductModel));
    }

    /**
     * 删除产品编号
     */
    @PreAuthorize("@ss.hasPermi('wcf:WcfProductModel:remove')")
    @Log(title = "产品编号", businessType = BusinessType.DELETE)
	@DeleteMapping("/{modelIds}")
    public AjaxResult remove(@PathVariable Long[] modelIds)
    {
        return toAjax(wcfProductModelService.deleteWcfProductModelByModelIds(modelIds));
    }
}
